<!DOCTYPE html>
<html lang="en">
<head th:replace="_fragment::head(~{::title})">
    <meta charset="UTF-8">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/me.css">
    <link rel="stylesheet" href="../../static/lib/editormd/css/editormd.css">
    <title>博客管理-发布</title>
</head>
<body>
<!--    导航-->
    <nav th:replace="_fragment::menu2(1)" class="ui inverted attached segment m-padded-tb-mini">
        <div class="ui container">
            <div class="ui inverted secondary menu">
                <h2 class="ui teal header item">后台管理</h2>
                <a href="#" class="active item"><i class=" home icon"></i>博客</a>
                <a href="#" class="item"><i class=" idea icon"></i>分类</a>
                <a href="#" class="item"><i class=" tags icon"></i>标签</a>
                <div class="right menu">
                    <div class="ui dropdown item">
                        <div class="text">
                            <img src="https://unsplash.it/100/100?image=1005" crossorigin="ui avatar image">
                            大鱼
                        </div>
                        <i class="dropdown icon"></i>
                        <div class="menu">
                            <a href="#" class="item">注销</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </nav>
    <div class="ui attached pointing menu">
        <div class="ui container">
            <div class="right menu">
                <a href="#" class="active teal item">发布</a>
                <a href="#" class="active teal item">列表</a>
            </div>

        </div>
    </div>
<!--中间内容-->
    <div class="m-padded-tb-large" style="max-width: 60em;margin: auto;">
        <div class="ui container">
            <form id="blog-from" th:action="@{/saveBlogs}" method="post" class="ui form">
                <input type="hidden" name="published">
                <div class="required field">
                    <div class="ui left labeled input">
                        <div class="ui selection compact teal basic dropdown label">
                            <input type="hidden" value="原创" name="flag">
                            <i class="dropdown icon"></i>
                            <div class="default text">原创</div>
                            <div class="menu">
                                <div class="item" data-value="原创">原创</div>
                                <div class="item" data-value="转载">转载</div>
                                <div class="item" data-value="翻译">翻译</div>
                            </div>
                        </div>
                        <input type="text" name="title" placeholder="标题">
                    </div>
                </div>
                <div class="required field">
                    <div id="md-content" style="z-index: 1">
                        <textarea placeholder="博客内容" name="content" style="display: none"></textarea>
                    </div>

                </div>

                <div class="two fields">
                    <div class="required field">
                        <div class="ui left labeled action input">
                            <label class="ui compact teal basic label">分类</label>
                            <div class="ui fluid selection dropdown">
                                <input type="hidden" name="typeid">
                                <i class="dropdown icon"></i>
                                <div class="default text">分类</div>
                                <div class="menu">
                                    <div class="item" th:each="type:${types}" th:data-value="${type.getId()}" th:text="${type.getName()}" data-value="1">错误日志</div>
<!--                                    <div class="item" data-value="2">开发者手册</div>-->
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui left labeled action input">
                            <label class="ui compact teal basic label">标签</label>
                            <div class="ui fluid multiple search selection dropdown">
                                <input type="hidden" name="tagList">
                                <i class="dropdown icon"></i>
                                <div class="default text">标签</div>
                                <div class="menu">
                                    <div class="item" th:each="tag:${tags}" th:data-value="${tag.getId()}" th:text="${tag.getName()}" data-value="Java">Java</div>
<!--                                    <div class="item" data-value="Python">Python</div>-->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="required field">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label">首图</label>
                        <input type="text" name="firstPicture" placeholder="首图引用地址">
                    </div>
                </div>

                <div class="ui error message"></div>
                <div class="ui right aligned container">
                    <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                    <button  class="ui secondary button" id="save-btn">保存</button>
                    <button class="ui teal button" id="publish-btn">发布</button>
                </div>
            </form>
        </div>
    </div>
<!--底部footer-->
<footer th:replace="_fragment::footer" class="ui inverted vertical segment m-padded-tb-massive">
    <div class="ui center aligned container">
        <div class="ui inverted divided grid">
            <div class="three wide column">
                <div class="ui inverted link list">
                    <div class="item">
                        <img src="../../static/images/1.jpg" class="ui rounded image" style="width: 110px">
                    </div>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header">最新博客</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">故事</a>
                    <a href="#" class="item">故事</a>
                    <a href="#" class="item">故事</a>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header">联系我</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">Emile:748835228@qq.com</a>
                    <a href="#" class="item">QQ: 748835228</a>
                </div>
            </div>
            <div class="seven wide column">
                <h4 class="ui inverted header">最新博客</h4>
                <p>111111111111111111111111111111</p>
            </div>
        </div>
        <div class="ui inverted section divider"></div>

    </div>
</footer>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
<script th:src="@{/lib/editormd/editormd.js}"></script>
<script>
    $('.ui.dropdown').dropdown({
        on:'hover'
    });

    $('.ui.form').form({
       fields : {
           title : {
               identifier: 'title',
               rules: [{
                   type : 'empty',
                   prompt: '标题：请输入博客标题'
               }]
           },
           content : {
               identifier: 'content',
               rules: [{
                   type : 'empty',
                   prompt: '内容：请输入博客内容'
               }]
           },
           typeid : {
               identifier: 'typeid',
               rules: [{
                   type : 'empty',
                   prompt: '分类：请输入博客分类'
               }]
           },
           firstPicture : {
               identifier: 'firstPicture',
               rules: [{
                   type : 'empty',
                   prompt: '首图：请输入博客首图'
               }]
           },
       }
    });

    //初始化markdown
    var contentEditor;
    $(function() {
        contentEditor = editormd("md-content", {
            width   : "100%",
            height  : 640,
            syncScrolling : "single",
            path    : "/lib/editormd/lib/"
        });
    });

    $('#save-btn').click(function (){
        $("[name='published']").val(1);
        $("#blog-from").submit();
    });

    $('#publish-btn').click(function (){
        $("[name='published']").val(2);
        $("#blog-from").submit();
    });


</script>
</body>
</html>